﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ResourceList.aspx.cs" Inherits="WebApplication.Admin.ResourceList"
    MasterPageFile="~/Admin/Admin.Master" %>

<asp:Content ID="head" runat="server" ContentPlaceHolderID="head">
    <script type="text/javascript">
        $(function () {
            $("#jqGrid").jqGrid({
                url: 'Handler.ashx?mode=GetResources',
                editurl: "Handler.ashx?mode=AddResource",
                datatype: "json",
                colNames: ['编号', '名称', '可见', "资源URI", '图标URI', '操作'],
                colModel: [
                { name: 'ID', hidden: true, key: true },
                { name: 'Name', width: 200, editable: true, editoptions: { maxlength: "100" }, editrules: { required: true} },
                { name: 'Visible', width: 30, editable: true, align: "center", edittype: "checkbox", editoptions: { value: "True:False", defaultValue: "True"} },
                { name: 'Url', align: "right", editable: true, width: 100, editoptions: { maxlength: "1024"} },
                { name: 'IconUrl', align: "right", editable: true, width: 100, editoptions: { maxlength: "1024"} },
                { name: $.jgrid.defaults.cleverjqgridactions,
                    sortable: false,
                    width: 40,
                    align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        var rId = options.rowId;
                        return "<div class=\"ui-corner-all ui-grid-btn-area \"><span title=\"删除\" class=\"ui-icon ui-icon-close\" onclick=\"DelArticle('" + rId + "')\"></span><span title=\"编辑\" class=\"ui-icon ui-icon-pencil\" onclick=\"UpdateArticle('" + rId + "')\" ></span></div>";
                    }
                }
                ],
                treeGrid: true,
                treedatatype: 'json',
                treeGridModel: 'adjacency',
                treeReader: {
                    level_field: 'tree_level',
                    parent_id_field: 'tree_parent',
                    leaf_field: 'tree_leaf',
                    expanded_field: 'tree_expanded',
                    loaded: 'tree_loaded',
                    icon_field: 'tree_icon'
                },
                ExpandColumn: 'Name',
                viewrecords: true,
                width: "100%",
                height: "100%",
                rowNum: 150,
                pager: "#jqGridPager",
                gridComplete: function () {
                    $("#jqGrid").setGridWidth($(window).width() - 10);
                }
            });

            var editOptions={ top:  ($(window).height() - 180) / 2, left: ($(window).width()-310)/2, width: 300,height:170,closeOnEscape: true,closeAfterEdit:true, afterSubmit: function(response, postdata){
                var data = $.parseJSON(response.responseText);return[data.Result,data.Message,data.ID];
            }};

            $("#jqGrid").jqGrid('navGrid','#jqGridPager',{edit:true,add:true,del:true,search:true},editOptions,editOptions,editOptions);//这里设定分页bar显示的信息
        });
    </script>
</asp:Content>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="main">
    <table id="jqGrid">
    </table>
    <div id="jqGridPager">
    </div>
</asp:Content>
<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="footer">
</asp:Content>
